package com.example.demo;

import ch.qos.logback.core.util.StringUtil;
import jakarta.servlet.http.HttpSession;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/login")
    public boolean login(String username, String password, HttpSession httpSession){
        if(StringUtil.isNullOrEmpty(username)||StringUtil.isNullOrEmpty(password)){
            return false;
        }
        if("admin".equals(username)&&"123456".equals(password)){
            httpSession.setAttribute("name",username);
            return true;
        }
        return false;
    }
}
